/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import ru.jSkyRoom.interfaces.major.Potion;
import ru.jSkyRoom.interfaces.stub.Addiction;
import ru.jSkyRoom.interfaces.stub.EquipSlot;
import ru.jSkyRoom.interfaces.stub.JSkySound;
import ru.jSkyRoom.interfaces.sub.Icon;
import ru.jSkyRoom.interfaces.sub.JSkyModel;
import skyproc.ALCH;
import skyproc.FormID;
import skyproc.Model;

/**
 *
 * @author Rakev
 */
public class PotionBridge extends MagicItemBridge<ALCH> implements Potion {

    public PotionBridge(ALCH adapting) {
        super(adapting);
    }

    @Override
    public JSkyModel getModel() {
        Model model = getRawObject().getModelData();
        return getBridgeFactory().createBridge(model);
    }

    @Override
    public JSkySound getPickupSound() {
        FormID soundId = getRawObject().getPickupSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setPickupSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setPickupSound(id);
    }

    @Override
    public JSkySound getDropSound() {
        FormID soundId = getRawObject().getDropSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setDropSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setDropSound(id);
    }

    @Override
    public JSkySound getUseSound() {
        FormID soundId = getRawObject().getUseSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setUseSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setUseSound(id);
    }

    @Override
    public int getValue() {
        return getRawObject().getValue();
    }

    @Override
    public void setValue(int value) {
        getRawObject().setValue(value);
    }

    @Override
    public boolean getFlag(ALCH.ALCHFlag flag) {
        return getRawObject().get(flag);
    }

    @Override
    public void setFlag(ALCH.ALCHFlag flag) {
        getRawObject().set(flag, true);
    }

    @Override
    public void unsetFlag(ALCH.ALCHFlag flag) {
        getRawObject().set(flag, false);
    }

    @Override
    public Addiction getAddiction() {
        FormID id = getRawObject().getAddiction();
        return getFinderFactory().createAddictionFinder().find(id);
    }

    @Override
    public void setAddiction(Addiction addiction) {
        FormID id = getIdProducer().produce(addiction);
        getRawObject().setAddiction(id);
    }

    @Override
    public float getWeight() {
        return getRawObject().getWeight();
    }

    @Override
    public void setWeight(float weight) {
        getRawObject().setWeight((float) weight);
    }

    @Override
    public Icon getInventoryIcon() {
        return new Icon() {
            @Override
            public String getFileName() {
                return getRawObject().getInventoryIcon();
            }

            @Override
            public void setFileName(String filename) {
                getRawObject().setInventoryIcon(filename);
            }
        };
    }

    @Override
    public Icon getMessageIcon() {
        return new Icon() {
            @Override
            public String getFileName() {
                return getRawObject().getMessageIcon();
            }

            @Override
            public void setFileName(String filename) {
                getRawObject().setMessageIcon(filename);
            }
        };
    }

    @Override
    public EquipSlot getEquipSlot() {
        FormID id = getRawObject().getEquipType();
        return getFinderFactory().createEquipSlotFinder().find(id);
    }

    @Override
    public void setEquipSlot(EquipSlot slot) {
        FormID id = getIdProducer().produce(slot);
        getRawObject().setEquipType(id);
    }
}
